<template>
	<!-- packageMy/myExchangeRecord/myExchangeRecord.wxml -->
	<view class="exchangeList">
		<view class="head-block" v-if="weixin == 2">
		 <view class="nav-title" :style="'top:10px'">兑换记录</view>
			<!-- 返回 -->
			<view class="icon" @tap="goMy" :style="'top:6px'">
				<van-icon name="arrow-left" color="#333" size="45rpx" />
			</view>
		</view>
		<block v-if="dataList && dataList.length > 0">
			<view class="thead">
				<view class="thead-item thead-item1">兑换时间</view>
				<view class="thead-item thead-item2">兑换积分</view>
				<view class="thead-item thead-item3">兑换内容</view>
			</view>
			<view class="exchange-item" v-for="(j, index) in dataList" :key="index">
				<view class="exchange-info exchange-info1">{{ j.createTime }}</view>

				<view class="exchange-info exchange-info2">-{{ j.integralAmount }}</view>

				<view class="exchange-info exchange-info3">{{ j.commodityName }}</view>
			</view>
		</block>
		<noData text="未查询到您的积分兑换记录" v-else />
		<!-- <view class="tip">温馨提示：本明细默认查询最近12个月的积分兑换记录（包含月），如有疑问，请联系社区管理人员。</view> -->
	</view>
</template>

<script>
	// packageMy/myExchangeRecord/myExchangeRecord.js
	const app = getApp();

	const api = require('../../utils/api.js');
	import util from '../../utils/util.js';
	import noData from '@/pages/components/noData/noData';
	export default {
		components: {
			noData
		},
		data() {
			return {
				// dataList:[{commodityName:'玻璃吸管杯',integralAmount:10,createTime:'2021-06-29 08:12'},
				// {commodityName:'玻璃吸管杯',integralAmount:10,createTime:'2021-06-29 08:12'},
				// {commodityName:'玻璃吸管杯',integralAmount:10,createTime:'2021-08-29 08:12'}],
				dataList: [],

				j: {
					createTime: '',
					integralAmount: '',
					commodityName: ''
				},
				weixin: uni.getStorageSync('weixin')
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad: function(options) {
			//取到的数据按日期分组
			this.exchangeRecord();
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		// onShareAppMessage: function () {
		// }
		onReachBottom: function() {},
		/**
		 * 用户点击右上角分享
		 */
		methods: {
			goMy() {
				uni.navigateBack({
					delta: 1
				});
			},
			exchangeRecord() {
				util.request(api.exchangeRecord, '', 'post')
					.then((res) => {
						//请求成功
						if (res.code == 0) {
							this.setData({
								dataList: res.data || []
							});
						} else {
							uni.showToast({
								title: res.msg || '服务器出小差了',
								icon: 'none'
							});
							this.setData({
								dataList: res.data
							});
						}
					})
					.catch((err) => {
						//请求失败
					});
			}
		}
	};
</script>
<style>
	@import './myExchangeRecord.css';
</style>
